#include <vector>
using std::vector;
#include <iostream>
class Solution
{
public:
    double findMedianSortedArrays(vector<int> &nums1, vector<int> &nums2)
    {
        vector<int> nums12;
        int len = nums1.size() + nums2.size();
        int zhongwei = (len / 2);
        vector<int>::iterator k;
        double sum = 0;
        if (zhongwei % 2 == 0)
        {
            int i = 0;
            while (i < zhongwei)
            {
                if (nums1[0] >= nums2[0])
                {
                    nums2.erase(nums2.begin());
                    i++;
                }
                else
                {
                    nums1.erase(nums1.begin());
                    i++;
                }
            }
            for (i = 0; i < 2; i++)
            {
                if (nums1[0] >= nums2[0])
                {
                    sum += nums2[0];
                    nums2.erase(nums2.begin());
                    i++;
                }
                else
                {
                    sum += nums1[0];
                    nums1.erase(nums1.begin());
                    i++;
                }
            }
            return sum / 2;
        }
        else
        {
            int i = 0;
            while (i < zhongwei)
            {
                if (nums1[0] >= nums2[0])
                {
                    nums2.erase(nums2.begin());
                    i++;
                }
                else
                {
                    nums1.erase(nums1.begin());
                    i++;
                }
            }
              if (nums1[0] >= nums2[0])
                {
                   return nums2[0];
                }
                else
                {
                   return nums1[0];
                }
        }
    }
};